<template>
	<view class="block" v-if="pageShow">
		<view class="erwmbox">
			<view class="flexcenter">
				<image class="touxiang margin_right1" :src="userInfo.avatar_text" mode=""></image>
				<view class="">
					<view class="ershiba zhonghei">{{userInfo.nickname}}</view>
					<view class="ershil xiaohei margin_top1">手机号：{{userInfo.mobile}}</view>
				</view>
			</view>
			<view class="flexcenter margin_top">
				<uqrcode ref="uqrcode" canvas-id="qrcode" @click="ewmfn" v-bind:value="qrcodeurl"
					:options="{ margin: 10}" size="150">
				</uqrcode>
			</view>
		</view>
		<button open-type="share" hover-class="none">
			<view class="flexcenter margin_top5">
				<image src="@/static/image/system/yqbtn.png" style="width: 370rpx;" mode="widthFix"></image>
			</view>
		</button>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				userInfo:{},
				pageShow:false,
				qrcodeurl:"",
			}
		},
		onLoad() {
			this.userinfomsg()
			this.getdata()
		},
		onShareAppMessage() {
			let _this = this
			return {
				title: "好物商城",
				path: "pages/homepage?code=" + uni.getStorageSync("invite_code"),
			}
		},
		methods: {
			// 二维码点击预览图片
			ewmfn() {
				this.$refs.uqrcode.toTempFilePath({
					success: res => {
						console.log(res);
						var i = [res.tempFilePath]; //获取当前页面的轮播图数据
						//uniapp预览轮播图
						uni.previewImage({
							current: 0, //预览图片的下标
							urls: i //预览图片的地址，必须要数组形式，如果不是数组形式就转换成数组形式就可以
						})
					}
				});
			},
			// // 获取链接
			getdata() {
				let _this = this;
				httpRequest.request('/api/index/getConfigInfo', 'GET', {}).then(res => {
					if (res.code == 1) {
						this.qrcodeurl = res.data.share_url + '?code=' + uni.getStorageSync("invite_code")
						this.pageShow = true
					}
				})
			},
			userinfomsg() {
				httpRequest.request('/api/user/index', 'GET', {}).then(res => {
					this.userInfo = res.data
					this.pageShow = true
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.erwm {
		width: 368rpx;
		height: 368rpx;
	}

	.touxiang {
		width: 86rpx;
		height: 86rpx;
		border-radius: 50%;
	}

	.erwmbox {
		background: #FFFFFF;
		padding: 52rpx 90rpx 67rpx;
		border-radius: 21rpx 21rpx 21rpx 21rpx;
	}

	.block {
		width: 100%;
		padding: 471rpx 100rpx 393rpx;
		// background-size: 100% 100%;
		box-sizing: border-box;
		// background-image: url('https://kangyuemei.yuntaiqikeji.com/uploads/20240122/6ce55fc902fe9023e02651e87ab05638.png');
		background: linear-gradient(180deg, #fe9550 0%, #fc6e1e 100%);
	}
</style>